package com.cyy.springbootinit.model.vo;

import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.cyy.springbootinit.model.entity.Building;
import com.cyy.springbootinit.model.entity.DormitoryExpenseBill;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 宿舍水电支出视图
 *
 * @author 程序员cyy</a>
 * @from cyy</a>
 */
@Data
public class DormitoryExpenseBillVO implements Serializable {

    /**
     * 自增整数，主键，支出单ID
     */
    @TableId(type = IdType.AUTO)
    private Integer billId;

    /**
     * 整数，宿舍ID（通过关联表实现关联，此处暂不体现外键）
     */
    private Integer dormitoryId;

    /**
     * 日期，账单日期
     */
    private Date billDate;

    /**
     * 浮点数，总支出金额
     */
    private Double totalExpense;

    /**
     * 浮点数，水费支出金额
     */
    private Double waterExpense;

    /**
     * 浮点数，电费支出金额
     */
    private Double electricityExpense;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 更新时间
     */
    private Date updateTime;


    //宿舍信息
    private DormitoryVO dormitoryVO;

    private static final long serialVersionUID = 1L;

    /**
     * 封装类转对象
     *
     * @param scoringResultVO
     * @return
     */
    public static DormitoryExpenseBill voToObj(DormitoryExpenseBillVO scoringResultVO) {
        if (scoringResultVO == null) {
            return null;
        }
        DormitoryExpenseBill scoringResult = new DormitoryExpenseBill();
        BeanUtils.copyProperties(scoringResultVO, scoringResult);
        return scoringResult;
    }

    /**
     * 对象转封装类
     *
     * @param
     * @return
     */
    public static DormitoryExpenseBillVO objToVo(DormitoryExpenseBill balanceWarning) {
        if (balanceWarning == null) {
            return null;
        }
        DormitoryExpenseBillVO scoringResultVO = new DormitoryExpenseBillVO();
        BeanUtils.copyProperties(balanceWarning, scoringResultVO);
        //scoringResultVO.setResultProp(JSONUtil.toList(scoringResult.getResultProp(), String.class));
        return scoringResultVO;
    }
}
